package com.chixing.service.impl;

import com.chixing.mapper.HotelMapper;
import com.chixing.pojo.Hotel;
import com.chixing.pojo.HotelExample;
import com.chixing.service.IndexHotelService;
import com.chixing.util.ServerResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class IndexHotelServiceImpl implements IndexHotelService {
    @Autowired
    private HotelMapper hotelMapper;

    @Override
    public ServerResponse getAll() {
        HotelExample hotelExample = new HotelExample();
        hotelExample.setOrderByClause("rand() limit 6");
        List<Hotel> hotelList = hotelMapper.selectByExample(hotelExample);
        if (hotelList != null && hotelList.size()>0)
            return ServerResponse.getSuccess(hotelList);
        return ServerResponse.getFail(null);
    }

}
